<html>
<head><meta charset="utf-8"><title>Movable Mutexes · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Movable.20Mutexes.html">Movable Mutexes</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="235706527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Movable%20Mutexes/near/235706527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Movable.20Mutexes.html#235706527">(Apr 22 2021 at 16:22)</a>:</h4>
<p><span class="user-mention" data-user-id="138938">@Jethro</span> you wanted to talk about movable mutexes?</p>



<a name="235716848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Movable%20Mutexes/near/235716848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Movable.20Mutexes.html#235716848">(Apr 22 2021 at 17:30)</a>:</h4>
<p>AFAIK that's only possible if we implement them ourselves (probably based on <code>parking_lot</code>).</p>



<a name="235717010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Movable%20Mutexes/near/235717010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Movable.20Mutexes.html#235717010">(Apr 22 2021 at 17:31)</a>:</h4>
<p>If we're willing to rely on implementation details then simply <code>memcpy</code>ing a <code>pthread_mutex_t</code> will work fine on glibc and musl, but I don't know about other targets.</p>



<a name="235717054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Movable%20Mutexes/near/235717054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Movable.20Mutexes.html#235717054">(Apr 22 2021 at 17:31)</a>:</h4>
<p>Same with windows slim RW locks.</p>



<a name="235729053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Movable%20Mutexes/near/235729053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Movable.20Mutexes.html#235729053">(Apr 22 2021 at 18:49)</a>:</h4>
<p>yeah, the question wasn't about unix but about tier 3/custom targets.</p>



<a name="237784339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Movable%20Mutexes/near/237784339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Movable.20Mutexes.html#237784339">(May 07 2021 at 08:14)</a>:</h4>
<p>must “MovableMutex” be movable while locked?<br>
and are there any unit tests that test moving it?</p>



<a name="237787627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Movable%20Mutexes/near/237787627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Movable.20Mutexes.html#237787627">(May 07 2021 at 08:45)</a>:</h4>
<p><span class="user-mention" data-user-id="138938">@Jethro</span> no, only in unlocked or 'forgotten' state. if there's any mutex guard still keeping it locked, it cannot be moved because it's borrowed.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>